package checksum

import (
	"crypto/md5"
	"fmt"
	"strings"
)

type Algorithm4Md5 struct {
	//	是否自动转为大写
	Upper bool
}

// Cal
//
//	@Description: 	md5算法,将目标字符串转为大写
//	@receiver a
//	@param value
//	@return string
func (a *Algorithm4Md5) Cal(value string) string {
	if len(value) <= 0 {
		return ""
	}
	hash := md5.New()
	hash.Write([]byte(value))
	tempValue := fmt.Sprintf("%x", hash.Sum(nil))
	if a.Upper {
		return strings.ToUpper(tempValue)
	}
	return tempValue
}
